package org.a;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Test3 {
	@SuppressWarnings("unused")
	public static void main(String[] args) {
		B a1= new B();
		Class<B> c= (Class<B>) a1.getClass();
		try {
			
			System.out.println(getsetStr("name"));
			/*Method m = c.getMethod("getName", null);
			Method m2 = c.getMethod("setName",String.class);
			Object o = m.invoke(a1, null);
			m2.invoke(a1, "222222222");
			System.out.println(o);*/
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	 /**
     * 根据字段字符串拼接出get方法名
     * @param item
     * @return
     */
    public static String getGetStr(String item){
        return "get"+item.substring(0,1).toUpperCase()+item.substring(1,item.length());
    }
    /**
     * 根据字段字符串拼接出set方法名
     * @param item
     * @return
     */
    public static String getsetStr(String item){
        return "set"+item.substring(0,1).toUpperCase()+item.substring(1,item.length());
    }
}

class A1{
	private String name="aaaa";
	private int id;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
}
class B extends A1{
	
}